; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=slp-vectorizer -S < %s -mtriple=aarch64 -aarch64-insert-extract-base-cost=3 | FileCheck %s

define void @test(<2 x i64> %0, <2 x i64> %1, <2 x i64> %2) {
; CHECK-LABEL: @test(
; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x i64> [[TMP1:%.*]], i64 0
; CHECK-NEXT:    [[TMP5:%.*]] = or i64 [[TMP4]], 0
; CHECK-NEXT:    [[TMP6:%.*]] = trunc i64 [[TMP5]] to i32
; CHECK-NEXT:    [[TMP7:%.*]] = extractelement <2 x i64> [[TMP0:%.*]], i64 0
; CHECK-NEXT:    [[TMP8:%.*]] = or i64 [[TMP7]], 0
; CHECK-NEXT:    [[TMP9:%.*]] = trunc i64 [[TMP8]] to i32
; CHECK-NEXT:    [[TMP10:%.*]] = extractelement <2 x i64> [[TMP2:%.*]], i64 0
; CHECK-NEXT:    [[TMP11:%.*]] = extractelement <2 x i64> [[TMP2]], i64 1
; CHECK-NEXT:    [[TMP12:%.*]] = or i64 [[TMP10]], [[TMP11]]
; CHECK-NEXT:    [[TMP13:%.*]] = trunc i64 [[TMP12]] to i32
; CHECK-NEXT:    [[TMP14:%.*]] = extractelement <2 x i64> [[TMP0]], i64 0
; CHECK-NEXT:    [[TMP15:%.*]] = or i64 [[TMP14]], 0
; CHECK-NEXT:    [[TMP16:%.*]] = trunc i64 [[TMP15]] to i32
; CHECK-NEXT:    br label [[TMP17:%.*]]
; CHECK:       17:
; CHECK-NEXT:    [[TMP18:%.*]] = phi i32 [ [[TMP22:%.*]], [[TMP17]] ], [ [[TMP6]], [[TMP3:%.*]] ]
; CHECK-NEXT:    [[TMP19:%.*]] = phi i32 [ 0, [[TMP17]] ], [ [[TMP9]], [[TMP3]] ]
; CHECK-NEXT:    [[TMP20:%.*]] = phi i32 [ 0, [[TMP17]] ], [ [[TMP13]], [[TMP3]] ]
; CHECK-NEXT:    [[TMP21:%.*]] = phi i32 [ 0, [[TMP17]] ], [ [[TMP16]], [[TMP3]] ]
; CHECK-NEXT:    [[TMP22]] = or i32 [[TMP18]], 0
; CHECK-NEXT:    br label [[TMP17]]
;
  %4 = extractelement <2 x i64> %1, i64 0
  %5 = or i64 %4, 0
  %6 = trunc i64 %5 to i32
  %7 = extractelement <2 x i64> %0, i64 0
  %8 = or i64 %7, 0
  %9 = trunc i64 %8 to i32
  %10 = extractelement <2 x i64> %2, i64 0
  %11 = extractelement <2 x i64> %2, i64 1
  %12 = or i64 %10, %11
  %13 = trunc i64 %12 to i32
  %14 = extractelement <2 x i64> %0, i64 0
  %15 = or i64 %14, 0
  %16 = trunc i64 %15 to i32
  br label %17

17:
  %18 = phi i32 [ %22, %17 ], [ %6, %3 ]
  %19 = phi i32 [ %23, %17 ], [ %9, %3 ]
  %20 = phi i32 [ %24, %17 ], [ %13, %3 ]
  %21 = phi i32 [ %25, %17 ], [ %16, %3 ]
  %22 = or i32 %18, 0
  %23 = add i32 0, 0
  %24 = add i32 0, 0
  %25 = add i32 0, 0
  br label %17
}
